
var ajaxStatus = true;
function ajax(type, url, data, success) {
    if (!ajaxStatus) {
        return false;
    }
    ajaxStatus = false;
    $.ajax({
        'type': type,
        'url': url,
        'data': data,
        'dataType': "json",
        'cache': false,
        'async': false,
        'success': success,
        'contentType': 'application/json;charset=utf-8',
        'beforeSend': function () {
            index = layer.msg('加载中', {
                icon: 16,
                shade: 0.01
            });
        },
        'complete': function () {
            layer.close(index);
        }
    });

    setTimeout(function () {
        ajaxStatus = true;
    }, 500);
}

function reviseTable (tip, url, data, successFunction) {
    var ajax = function () {
        $.ajax({
            url: url,
            data: data,
            type: 'get',
            dateType: 'json',
            'contentType': 'application/json;charset=utf-8',
            'beforeSend': function () {
                index = layer.msg('加载中', {
                    icon: 16,
                    shade: 0.01
                });
            }, complete: function () {
                layer.close(index);
            }, success: function (res) {
                if (res.success === true) {
                    layer.msg(res.message);
                    if (successFunction == null) {
                        setTimeout(function () {
                            $('#table').bootstrapTable('refresh');
                        }, 1000);
                    } else {
                        successFunction();
                    }
                } else if (res.success === false) {
                    layer.alert(res.message);
                }
            }, error: function (e) {
                console.log(e);
            }
        });
    };

    if (tip) {
        confirm = layer.confirm(tip, {
            btn: ['确定', '取消']
        }, function () {
            layer.close(confirm);
            ajax();
        }, function () {
            layer.close(confirm);
        });
    } else {
        ajax();
    }
}


